/*************************************************************
 * Title: Operator.java
 * Description: 
 * Author: Huang Shaobin
 * Email: shaobin.software@gmail.com
 * CreateTime: Feb 21, 2013 2:32:49 PM
 ************************************************************/
package snow.core.security;

import org.apache.commons.lang.ArrayUtils;

/**
 * 权限
 */
public enum Operator {

	SEARCH(0x0), CREATE(0x1), REMOVE(0x2), MODIFY(0x3);

	public static Operator toOperatorFrom(int value) {
		final Operator[] operators = values();
		if (!ArrayUtils.isEmpty(operators)) {
			for (Operator operator : operators) {
				if (operator != null && operator.getValue() == value) {
					return operator;
				}
			}
		}
		return null;
	}

	private final int value;

	private Operator(int value) {
		this.value = value;
	}

	public int getValue() {
		return value;
	}

}
